package com.sitanyun.merchant.guide.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.sitanyun.merchant.guide.R;
import com.sitanyun.merchant.guide.bean.EnterShopDialsBean;

import java.util.List;

/**
 * Created by jzl
 * on 2022/1/10.
 */
public class ShopEntersAdapter extends BaseAdapter {
    private Context context;
    private List<EnterShopDialsBean.DataBean.RecordsBean> recordsBeanList;
   private  List<String> lists;


    public ShopEntersAdapter(Context context, List<EnterShopDialsBean.DataBean.RecordsBean> recordsBeanList, List<String> lists) {
        this.context = context;
        this.recordsBeanList = recordsBeanList;
        this.lists = lists;
    }

    @Override
    public int getCount() {
        return recordsBeanList.size();
    }

    @Override
    public Object getItem(int position) {
        return recordsBeanList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView=  LayoutInflater.from(context).inflate(R.layout.shopenter_item,null);
       TextView shopentername  = convertView.findViewById(R.id.shopenter_name);
        TextView  shopentershar = convertView.findViewById(R.id.shopenter_shar);

        TextView  shopenternums = convertView.findViewById(R.id.shopenter_num);
        ImageView shopenterimgs  = convertView.findViewById(R.id.shopenter_imgs);

        ImageView shopenterimg  = convertView.findViewById(R.id.shopenter_img);
        View  shopenterview = convertView.findViewById(R.id.shop_view);
        View  shopenterviews = convertView.findViewById(R.id.shop_views);
        shopentername.setText(recordsBeanList.get(position).getStaffName()+"");
        shopentershar.setText(recordsBeanList.get(position).getShareCnt()+"");
        Glide.with(context).load(recordsBeanList.get(position).getAvatar()).error(R.mipmap.cimg).into(shopenterimg);
        if (position==0){
            shopenterview.setVisibility(View.VISIBLE);
            shopenterviews.setVisibility(View.GONE);
        }else {
            shopenterview.setVisibility(View.GONE);
            shopenterviews.setVisibility(View.VISIBLE);
        }
           if (lists.get(position).equals("0")){
               shopenternums.setVisibility(View.GONE);
               shopenterimgs.setVisibility(View.VISIBLE);
               Glide.with(context).load(R.mipmap.one).into(shopenterimgs);

           }else if (lists.get(position).equals("1")){
               shopenternums.setVisibility(View.GONE);
               shopenterimgs.setVisibility(View.VISIBLE);
               Glide.with(context).load(R.mipmap.two).into(shopenterimgs);
           }else if (lists.get(position).equals("2")){
               shopenternums.setVisibility(View.GONE);
               shopenterimgs.setVisibility(View.VISIBLE);
               Glide.with(context).load(R.mipmap.three).into(shopenterimgs);
           }else {
               shopenternums.setVisibility(View.VISIBLE);
               shopenterimgs.setVisibility(View.GONE);
             String  num = lists.get(position);
               int a =Integer.parseInt(num);
               int b=a + 1;
               String s = Integer.toString(b);
               shopenternums.setText(s+"");
           }


        return convertView;

    }
}
